﻿<UserControl x:Class="AOUtils.Libraries.NumericUpDown"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="clr-namespace:AOUtils.Libraries" Height="23" Width="55">
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition/>
            <RowDefinition/>
        </Grid.RowDefinitions>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="37.656*" />
            <ColumnDefinition Width="16.344*" />
        </Grid.ColumnDefinitions>
        <Border BorderThickness="1" BorderBrush="Gray" Margin="0" 
                Grid.RowSpan="2" Grid.ColumnSpan="2"/>
        <Border BorderThickness="1" BorderBrush="Gray" Margin="0" 
                Grid.RowSpan="2">
            <!--Bind the TextBlock to the Value property-->
            <TextBox Grid.Column="0" Grid.ColumnSpan="1" Grid.RowSpan="2" Name="inputTextBox" TextAlignment="Right" VerticalContentAlignment="Center" HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
                <TextBox.Text>
                    <Binding Mode="TwoWay" NotifyOnSourceUpdated="True" NotifyOnTargetUpdated="True" UpdateSourceTrigger="PropertyChanged" Path="Value" 
                             RelativeSource="{RelativeSource FindAncestor, AncestorType={x:Type local:NumericUpDown}}">
                        <Binding.ValidationRules>
                            <local:LevelValidationRule />
                        </Binding.ValidationRules>
                    </Binding>
                </TextBox.Text>
            </TextBox>
        </Border>
        <RepeatButton Name="upButton" Click="upButton_Click" Grid.Column="1" Margin="0,1,1,0">
            <Image Name="upImage" HorizontalAlignment="Stretch" VerticalAlignment="Stretch"></Image>
        </RepeatButton>
        <RepeatButton Name="downButton" Click="downButton_Click" Grid.Column="1" Margin="0,0,1,1" Grid.Row="1">
            <Image Name="downImage"></Image>
        </RepeatButton>
    </Grid>
</UserControl>
